package com.yixiu.modules.swagger;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
@Validated
//@Api 用在类上，说明该类的作用
@Api(value = "USER", description = "测试UserController")
public class UserController {
    private  Logger logger = LoggerFactory.getLogger(this.getClass());




    @RequestMapping(value="",method={RequestMethod.GET })
    // ApiOperation 用在方法上，说明方法的作用
    @ApiOperation(value = "查询个人信息接口",notes = "查询个人信息接口")
    // @ApiImplicitParams  用在方法上包含一组参数说明

    /*
    @ApiImplicitParam
    用在@ApiImplicitParams注解中，指定一个请求参数的各个方面
    paramType：参数放在哪个地方
    header–>请求参数的获取：@RequestHeader
    query–>请求参数的获取：@RequestParam
    path（用于restful接口）–>请求参数的获取：@PathVariable
    body（不常用）
    form（不常用）
    name：参数名
    dataType：参数类型
    required：参数是否必须传
    value：参数的意思
    defaultValue：参数的默认值
*/

    @ApiImplicitParams({ @ApiImplicitParam(paramType = "header", dataType="string", name = "token", value = "访问凭证", required = true), })
    public List<String> query(@RequestParam("page") int page,@RequestParam("count") int count) {
        logger.info(String.valueOf(page) + "   " + String.valueOf(count));

        List<String> list = new ArrayList<>();
        list.add("aa");
        list.add("bb");
        return list;
    }

    @RequestMapping(value="",method={RequestMethod.POST })
    @ApiOperation(value = "增加个人信息接口",notes = "增加个人信息接口")
    public void insert(@RequestAttribute("name") String name) {
        logger.info(name);
    }
}
